package cn.ys.base.service.impl;

import cn.ys.base.enm.ShopEnum;
import cn.ys.base.service.EchartsService;
import cn.ys.org.mapper.ShopMapper;
import cn.ys.org.vo.MiddleVo;
import cn.ys.org.vo.ShopVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class EchartsServiceImpl implements EchartsService {

    @Autowired
    private ShopMapper mapper;

    @Override
    public ShopVo echarts() {
        ShopVo ShopVo = new ShopVo();

        List<MiddleVo> middleVos = mapper.echarts();

        List<String> x = middleVos.stream().map(middle -> ShopEnum.getNameByCode(middle.getX())).collect(Collectors.toList());
        ShopVo.setX(x);
        List<String> y = middleVos.stream().map(middle -> ShopEnum.getNameByCode(middle.getY())).collect(Collectors.toList());
        ShopVo.setY(y);
        return ShopVo;
    }
}
